package homework.linked;

import java.util.Iterator;
import java.util.LinkedList;

public class MyStack {
    public static void main(String[] args) {
        LinkedList push = new LinkedList();
        push.add(0,"图书");
        push.add(1,"电脑");
        push.add(2,"手机");

        System.out.println("现有元素如下:");
        Iterator it = push.listIterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("删除头部元素结果为：");
        push.removeFirst();
        Iterator item = push.listIterator();
        while (item.hasNext()){
            System.out.println(item.next());
        }

        System.out.println("最后一个元素为："+push.getLast());
        if (push.isEmpty()){
            System.out.println("集合为空！");
        }else {
            System.out.println("集合不为空！");
        }

        System.out.println("集合有："+push.size()+"个元素");

    }
}


